#!/bin/bash 

#auther:DT

jia_bc(){
read -p "请输入两个数，用空格把它隔开:" one two
if echo $one $two |egrep "\." &>/dev/null
then
sum=`echo "scale=2;$one+$two"|bc` 
echo "$one + $two =  $sum"
else
echo "$one + $two =" $((one+two))
fi
}

jian_bc(){
read -p "请输入两个数，用空格把它隔开:" one two 
if (($one >= $two ))
then
	if echo $one $two |egrep "\." &>/dev/null
	then
		sum=`echo "scale=2;$one-$two"|bc` 
		echo "$one - $two =  $sum"
	else
		echo "$one - $two =" $((one-two))
	fi
else
	echo "err"
fi
}

chen_bc(){
d -p "请输入两个数，用空格把它隔开:" one two 
if echo $one $two |egrep "\." &>/dev/null
then
sum=`echo "scale=2;$one*$two"|bc` 
echo "$one * $two =  $sum"
else
echo "$one * $two =" $((one*two))
fi
}

chu_bc(){
read -p "请输入两个数，用空格把它隔开:" one two
	sum=`echo "scale=2;scale=2;$one/$two"|bc` 
if (($one >= $two))
then
	echo "$one / $two =  $sum"
else
	echo "$one / $two =  0$sum"
fi
}


quyu_bc(){
read -p "请输入两个数，用空格把它隔开:" one two
sum=`echo "$one%$two"|bc` 
echo "$one % $two =  $sum"
}
main_menu(){
read -p "1,+ 2,- 3,* 4,/ 5,%" option
case $option in 
1)
jia_bc
;;
2)
jian_bc
;;
3)
chen_bc
;;
4)
chu_bc
;;
5)
quyu_bc
;;
esac
}
while :
do
main_menu
done
